package com.catietie.bookmanagement.config;

import com.catietie.bookmanagement.intercepter.JwtTokenUserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置拦截信息
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JwtTokenUserInterceptor())
             .addPathPatterns("/api/**") // 需要拦截并验证 JWT 的路径
             .excludePathPatterns("/api/user/**"); // 不需要拦截的路径
    }
}